package sip;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Simple Basal Profile Class
 * @author Stephen
 */
public class BasalProfile {
    
    public float[] profile = new float[24];
    
    ///Use to save the basal profile
    public void saveProfile() {
        try {
//            PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("BasalProfiles.txt", true))); //append to file
            PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("BasalProfiles.txt", false))); //overwrite file
            for(int iter = 0; iter < 24; iter++)
            {
                out.println( profile[iter] );                
            }
            out.close();
        } catch (IOException e) {
            System.out.println("ERROR:  Exception:  " + e.toString());
        }
    }
    
    public void display() {
        for(int iter = 0; iter < 24; iter++) {
            System.out.println("Hour:\t" + iter + "\tRate:\t" + profile[iter]);
        }
    }
    ///Used for testing this class
//    public static void main (String args[]) {
//         BasalProfile myProfile = new BasalProfile();
//         for(int iter = 0; iter < 24; iter++)
//         {
//             myProfile.profile[iter] = iter + 1;
//         }
//         myProfile.saveProfile();
//    }
}
